package com.appwoo.txtws.thread;

import android.os.AsyncTask;
import android.os.Handler;
import android.os.Message;
import com.appwoo.txtws.component.Global;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class ImageDownloadTask extends AsyncTask<Object, Integer, String>
{
  protected String doInBackground(Object[] paramArrayOfObject)
  {
    String str1;
    if (Global.isSDCard())
      str1 = Global.IMGPATH;
    while (true)
    {
      String str2 = (String)paramArrayOfObject[0];
      String str3 = str2.substring(1 + str2.lastIndexOf("/"), str2.lastIndexOf("."));
      try
      {
        BufferedInputStream localBufferedInputStream = new BufferedInputStream(((HttpURLConnection)new URL(str2).openConnection()).getInputStream());
        FileOutputStream localFileOutputStream = new FileOutputStream(str1 + str3);
        BufferedOutputStream localBufferedOutputStream = new BufferedOutputStream(localFileOutputStream);
        byte[] arrayOfByte = new byte[4096];
        while (true)
        {
          int i = localBufferedInputStream.read(arrayOfByte);
          if (i <= 0)
          {
            localBufferedOutputStream.flush();
            localBufferedOutputStream.close();
            localFileOutputStream.close();
            localBufferedInputStream.close();
            Message localMessage2 = ((Handler)paramArrayOfObject[1]).obtainMessage();
            localMessage2.obj = (str1 + str3);
            localMessage2.sendToTarget();
            String str4 = str1 + str3;
            return str4;
            str1 = Global.IMGPATHMEMORY;
            break;
          }
          localBufferedOutputStream.write(arrayOfByte, 0, i);
        }
      }
      catch (Exception localException)
      {
        Message localMessage1 = ((Handler)paramArrayOfObject[1]).obtainMessage();
        localMessage1.obj = null;
        localMessage1.sendToTarget();
        File localFile = new File(str1 + str3);
        if (localFile.exists())
          localFile.delete();
      }
    }
    return null;
  }

  protected void onCancelled()
  {
    super.onCancelled();
  }

  protected void onPostExecute(String paramString)
  {
    super.onPostExecute(paramString);
  }

  protected void onPreExecute()
  {
    super.onPreExecute();
  }

  protected void onProgressUpdate(Integer[] paramArrayOfInteger)
  {
    super.onProgressUpdate(paramArrayOfInteger);
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.thread.ImageDownloadTask
 * JD-Core Version:    0.6.2
 */